﻿using Architecture.Api.Application.Commands.RoleCommand;
using Architecture.Domain.Services.Interface;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleCreateCommandHandler : IRequestHandler<RoleCreateCommand, int>
    {
        private readonly IRoleSerivce _roleService;

        public RoleCreateCommandHandler(IRoleSerivce roleService)
        {
            _roleService = roleService;
        }

        public async Task<int> Handle(RoleCreateCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.RoleInsert(new Domian.Entity.RoleInfo { RoleName = request.RoleName });
        }
    }
}
